<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "call_center".
 *
 * @property int $id 主键id
 * @property string $post_code 邮政编码
 * @property int $memberclassify_id 客户分类
 * @property int $productclassify_id 咨询产品id
 * @property int $membertype_id 来电类型
 * @property int $mem_type 客户质量
 * @property string $sick_id 病症组合 id
 * @property string $member_name 客户名
 * @property int $sex 性别 默认0 女 1 男 2 保密
 * @property string $home_phone 家庭电话
 * @property string $mobile 手机号码
 * @property string $other_phone 其他电话（家人朋友等）
 * @property string $profession 客户职业
 * @property string $work_phone 工作电话
 * @property string $years 病领
 * @property string $pro_name 省
 * @property string $visit_result 回访结果
 * @property int $visitemployee_id 回访者id
 * @property string $like 爱好
 * @property string $city_name 市名
 * @property string $locate_name 位置
 * @property string $detail_address 详细地址
 * @property int $vip_card 会员卡号
 * @property int $totalbuymoney 消费总金额
 * @property int $lastemployee_id 最后联系员工id
 * @property int $owneremployee_id 拥有者id
 * @property int $lastseat_number 坐席号
 * @property string $lastseat_ip 坐席ip
 * @property string $memo 沟通内容
 * @property string $buy_address 购买地址
 * @property int $buy_times 购买次数
 * @property int $buy_date 购买日期
 * @property int $returncard_date 退货日期
 * @property int $buy_product 购买的产品
 * @property int $vip_type vip类型
 * @property string $age 年龄
 * @property int $integral 积分
 * @property int $grade_id 等级
 * @property int $member_code 客户编号 
 * @property int $member_grade 客户等级
 * @property string $income 收入
 * @property int $member_owner 客户拥有者
 * @property int $webmember_id
 * @property string $nick_name 昵称
 * @property string $identity_card 身份证号
 * @property string $email 邮箱
 * @property int $birthday 生日
 * @property int $total_integral 总积分
 * @property int $dispatch_times 派件次数
 * @property string $share_numbers 共享工号：Num1/Num2/...Numn/
 * @property int $is_used 0回收池，1话务，2回访（已分配），3共同（已分配但又来电）
 * @property int $mem_source 客户来源：电视导购、报纸等
 * @property int $dispatchemp_id 上次分配人id
 * @property int $mem_require 客户需求：相当于产品大类
 * @property string $medicine_id 用药id
 * @property string $education 教育
 * @property int $dispatch_flag 派件标记 已发货、在路上、已签收等
 * @property string $home_history 家庭病史
 * @property string $children
 * @property string $examine 检查情况
 * @property string $sick_name 病症名称
 * @property string $medicine_name 是否影响用药，看看体重等别的情况
 * @property string $wechat 微信号
 * @property int $is_public 是否为公共的
 * @property int $custsale_grade 客户销售等级
 * @property string $imeino 血压
 * @property int $subscribeno 预约号
 * @property int $import_date 导入时间
 * @property int $time_out 到期时间
 * @property int $nextvisit_time 下次回访时间
 * @property int $ishold 是否暂存  0 否 1 是
 * @property int $dispatch_date 派件时间
 * @property int $lastdate_time 最后联系时间
 * @property int $add_date 添加时间
 * @property int $isblack 是否拉黑
 * @property int $update_time 更新时间
 */
class CallCenter extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'call_center';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['memberclassify_id', 'productclassify_id', 'membertype_id', 'mem_type', 'sex', 'visitemployee_id', 'vip_card', 'totalbuymoney', 'lastemployee_id', 'owneremployee_id', 'lastseat_number', 'buy_times', 'buy_date', 'returncard_date', 'buy_product', 'vip_type', 'integral', 'grade_id', 'member_code', 'member_grade', 'member_owner', 'webmember_id', 'birthday', 'total_integral', 'dispatch_times', 'is_used', 'mem_source', 'dispatchemp_id', 'mem_require', 'dispatch_flag', 'is_public', 'custsale_grade', 'subscribeno', 'import_date', 'time_out', 'nextvisit_time', 'ishold', 'dispatch_date', 'lastdate_time', 'add_date', 'isblack', 'update_time'], 'integer'],
            [['post_code'], 'string', 'max' => 10],
            [['sick_id', 'like', 'medicine_id', 'home_history', 'children'], 'string', 'max' => 100],
            [['member_name', 'income', 'wechat'], 'string', 'max' => 30],
            [['home_phone', 'mobile', 'other_phone', 'work_phone', 'identity_card'], 'string', 'max' => 20],
            [['profession', 'pro_name', 'city_name', 'email', 'education', 'imeino'], 'string', 'max' => 50],
            [['years', 'visit_result', 'locate_name', 'nick_name'], 'string', 'max' => 60],
            [['detail_address'], 'string', 'max' => 200],
            [['audio'], 'string', 'max' => 100],
            [['lastseat_ip'], 'string', 'max' => 64],
            [['memo', 'share_numbers', 'examine', 'sick_name', 'medicine_name'], 'string', 'max' => 255],
            [['buy_address'], 'string', 'max' => 150],
            [['age'], 'string', 'max' => 11],
            [['add_date'], 'default', 'value'=>time()],
            [['update_time'],'default','value'=>time()],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'post_code' => 'Post Code',
            'memberclassify_id' => 'Memberclassify ID',
            'product_id'=>'Product ID',
            'productclassify_id' => 'Productclassify ID',
            'membertype_id' => 'Membertype ID',
            'mem_type' => 'Mem Type',
            'sick_id' => 'Sick ID',
            'member_name' => 'Member Name',
            'sex' => 'Sex',
            'home_phone' => 'Home Phone',
            'mobile' => 'Mobile',
            'other_phone' => 'Other Phone',
            'profession' => 'Profession',
            'work_phone' => 'Work Phone',
            'years' => 'Years',
            'pro_name' => 'Pro Name',
            'visit_result' => 'Visit Result',
            'visitemployee_id' => 'Visitemployee ID',
            'like' => 'Like',
            'city_name' => 'City Name',
            'locate_name' => 'Locate Name',
            'detail_address' => 'Detail Address',
            'vip_card' => 'Vip Card',
            'totalbuymoney' => 'Totalbuymoney',
            'lastemployee_id' => 'Lastemployee ID',
            'owneremployee_id' => 'Owneremployee ID',
            'lastseat_number' => 'Lastseat Number',
            'lastseat_ip' => 'Lastseat Ip',
            'memo' => 'Memo',
            'buy_address' => 'Buy Address',
            'buy_times' => 'Buy Times',
            'buy_date' => 'Buy Date',
            'returncard_date' => 'Returncard Date',
            'buy_product' => 'Buy Product',
            'vip_type' => 'Vip Type',
            'age' => 'Age',
            'integral' => 'Integral',
            'grade_id' => 'Grade ID',
            'member_code' => 'Member Code',
            'member_grade' => 'Member Grade',
            'income' => 'Income',
            'member_owner' => 'Member Owner',
            'webmember_id' => 'Webmember ID',
            'nick_name' => 'Nick Name',
            'identity_card' => 'Identity Card',
            'email' => 'Email',
            'birthday' => 'Birthday',
            'total_integral' => 'Total Integral',
            'dispatch_times' => 'Dispatch Times',
            'share_numbers' => 'Share Numbers',
            'is_used' => 'Is Used',
            'mem_source' => 'Mem Source',
            'dispatchemp_id' => 'Dispatchemp ID',
            'mem_require' => 'Mem Require',
            'medicine_id' => 'Medicine ID',
            'education' => 'Education',
            'dispatch_flag' => 'Dispatch Flag',
            'home_history' => 'Home History',
            'children' => 'Children',
            'examine' => 'Examine',
            'sick_name' => 'Sick Name',
            'medicine_name' => 'Medicine Name',
            'wechat' => 'Wechat',
            'is_public' => 'Is Public',
            'custsale_grade' => 'Custsale Grade',
            'imeino' => 'Imeino',
            'subscribeno' => 'Subscribeno',
            'import_date' => 'Import Date',
            'time_out' => 'Time Out',
            'nextvisit_time' => 'Nextvisit Time',
            'ishold' => 'Ishold',
            'dispatch_date' => 'Dispatch Date',
            'lastdate_time' => 'Lastdate Time',
            'add_date' => 'Add Date',
            'isblack' => 'Isblack',
            'update_time' => 'Update Time',
        ];
    }

    public function getVipType()
    {
        return $this->hasOne(VipType::className(), ['id' => 'vip_type']);
    }

    /**
     * @return \yii\db\ActiveQuery
     * 关联user
     */
    public function getUser()
    {
        return $this->hasOne(User::className(), ['id' => 'member_owner']);
    }
}
